package com.pangu.ui.refresh;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import com.pangu.task.mark.ATaskMark;
import com.pangu.ui.R;
import com.pangu.ui.browser.LoadableList;

/**
 * 刷新控制器
 * Created by panxiaodong_91 on 2015/8/3.
 */
public abstract class RefreshControllerView extends ARefreshViewController implements ARefreshViewController
        .OnRefreshListener {

    public RefreshControllerView(Context context) {
        super(context);

        setOnRefreshListener(this);
    }

    public RefreshControllerView(Context context, AttributeSet attrs) {
        super(context, attrs);

        setOnRefreshListener(this);
    }

    @Override
    protected View createRefreshHeaderView() {
        return new PullToRefreshView(getContext());
    }

    @Override
    protected View createRefreshFooterView() {
        return new PullToLoadMoreView(getContext());
    }

    @Override
    protected ATaskMark createTaskMark() {
        return null;
    }

    @Override
    public void onLoadMore(ARefreshViewController controller) {

    }

    public void scrollUp() {
        if (content instanceof LoadableList) {
            ((LoadableList) content).scrollUp();
        }
    }

    public void setScrollListener(LoadableList.LoadableListScrollListener listener) {
        if (content instanceof LoadableList) {
            LoadableList loadableList = (LoadableList) content;
            loadableList.setLoadableListScrollListener(listener);
        }
    }
}
